import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { getDepartmentsByUnitCode } from '/@/api/system/system';

export const columns: BasicColumn[] = [
  {
    title: '用户',
    dataIndex: 'realName',
  },
  {
    title: '部门',
    dataIndex: 'deptName',
  },
  {
    title: 'PC登录',
    dataIndex: 'loginTime',
  },
  {
    title: 'PC端IP',
    dataIndex: 'ip',
  },
  {
    title: 'PC在线',
    dataIndex: 'stayTime',
  },
  {
    title: '移动端登录',
    dataIndex: 'loginTimeMobile',
  },
  {
    title: '移动端在线',
    dataIndex: 'stayTimeMobile',
  },
  {
    title: '移动端IP',
    dataIndex: 'ip_mobile',
  },
  {
    title: 'PC',
    dataIndex: 'client',
  },
  {
    title: '移动端',
    dataIndex: 'clientMobile',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'realName',
    label: '用户',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'deptCode',
    label: '部门',
    component: 'ApiTreeSelect',
    componentProps: {
      api: getDepartmentsByUnitCode,
      treeDefaultExpandAll: true,
      multiple: false,
      resultField: 'list',
      showSearch: true,
      treeNodeFilterProp: 'name',
      fieldNames: {
        label: 'name',
        key: 'code',
        value: 'code',
      },
      getPopupContainer: () => document.body,
    },
    colProps: { span: 6 },
  },
  {
    field: 'clientMobile',
    label: '移动端',
    component: 'Select',
    colProps: { span: 6 },
    componentProps: {
      options: [
        {
          value: '',
          label: '不限',
        },
        {
          value: 'Android',
          label: '安卓',
        },
        {
          value: 'IOS',
          label: '苹果',
        },
      ],
    },
  },
  {
    field: 'ip',
    label: 'IP',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    field: 'dates',
    label: 'PC端登录',
    component: 'RangePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
      placeholder: ['开始时间', '结束时间'],
      showTime: false,
      style: 'width:100%',
      getPopupContainer: () => document.body,
    },
    colProps: { sm: 8, lg: 8, md: 8, xl: 8, xxl: 6 },
  },
  {
    field: 'datesMobile',
    label: '移动端登录',
    component: 'RangePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
      placeholder: ['开始时间', '结束时间'],
      showTime: false,
      style: 'width:100%',
      getPopupContainer: () => document.body,
    },
    colProps: { sm: 8, lg: 8, md: 8, xl: 8, xxl: 6 },
  },
];
